yugiohdecksfandomcom_es-20200216-history
Módulo:RecetaDeck
local p = {} local html = {} function p.decks(frame) local sortcardnames = {} local cardnames = {} local maindeck = {} local extradeck = {} local sidedeck = {} local text = '' for name, value in pairs(frame.args) do if value ~= '' then local cardname = p.normalize(value) local index = string.lower(name) local letter = string.sub(index, 0, 1) if letter 'd' then maindeckindex = cardname else if letter 'e' then extradeckindex = cardname else if letter 's' then sidedeckindex = cardname end end end if cardnamescardname nil then cardnamescardname = {} table.insert(sortcardnames, cardname) end end end table.sort(sortcardnames) cardnames = p.getCardsData(sortcardnames) text = html.deck(maindeck, extradeck, sidedeck, cardnames) return text end function p.getCardsData(sortcardnames) local temp = {} local RdDatos = {} local RdLetter = '' for i, n in ipairs(sortcardnames) do local Letter = p.selectLetter(string.sub(n, 0, 1)) if RdLetter ~= Letter then RdLetter = Letter RdDatos = require('Módulo:RdDatos' .. RdLetter) end if RdDatosn ~= nil then local rddatos = RdDatosn tempn = {} tempn'nombre' = rddatos1 tempn'ingles' = rddatos2 tempn'carta' = rddatos3 tempn'atributo' = rddatos4 tempn'tipo' = rddatos5 if rddatos4 ~= 'mágica' and rddatos4 ~= 'trampa' then tempn'nivel' = rddatos6 tempn'ataque' = rddatos7 tempn'defensa' = rddatos8 end end end return temp end function p.selectLetter(letter) local a = { 'A' = 'A', 'B' = 'B', 'C' = 'C', 'D' = 'D', 'E' = 'E', 'F' = 'F', 'G' = 'G', 'H' = 'H', 'I' = 'I', 'J' = 'J', 'K' = 'K', 'L' = 'L', 'M' = 'M', 'N' = 'N', 'O' = 'O', 'P' = 'P', 'Q' = 'Q', 'R' = 'R', 'S' = 'S', 'T' = 'T', 'U' = 'U', 'V' = 'V', 'W' = 'W', 'X' = 'X', 'Y' = 'Y', 'Z' = 'Z' } letter = aletter or '7' return letter end function p.normalize (cardname) cardname = string.lower(cardname) cardname = string.gsub(cardname, 'á', 'a') cardname = string.gsub(cardname, 'ä', 'a') cardname = string.gsub(cardname, 'é', 'e') cardname = string.gsub(cardname, 'ë', 'e') cardname = string.gsub(cardname, 'í', 'i') cardname = string.gsub(cardname, 'ï', 'i') cardname = string.gsub(cardname, 'ó', 'o') cardname = string.gsub(cardname, 'ö', 'o') cardname = string.gsub(cardname, 'ú', 'u') cardname = string.gsub(cardname, 'ü', 'u') cardname = string.upper(cardname) cardname = string.gsub(cardname, ' ', ) cardname = string.gsub(cardname, '"', '') cardname = string.gsub(cardname, "'", '') cardname = string.gsub(cardname, ',', '') cardname = string.gsub(cardname, '%.', '') cardname = string.gsub(cardname, '%-', '') cardname = string.gsub(cardname, '¡', '') cardname = string.gsub(cardname, '!', '') cardname = string.gsub(cardname, '¿', '') cardname = string.gsub(cardname, '%?', '') cardname = string.gsub(cardname, ':', '') cardname = string.gsub(cardname, 'º', '') cardname = string.gsub(cardname, '/', '') cardname = string.gsub(cardname, '#', '') cardname = string.gsub(cardname, '&', 'Y') cardname = string.gsub(cardname, 'ñ', 'Ñ') return cardname end function p.convnombreimagen(filename) filename = string.lower(filename) filename = string.gsub(filename, '/', '-') filename = string.gsub(filename, ', ) filename = string.gsub(filename, '\, '') filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '?', '') filename = string.gsub(filename, 'f;', '') return filename end function html.deck (maindeck, extradeck, sidedeck, cardnames) local text = '' -- Tab: Vista Principal text = text .. 'Vista Principal =\n' -- Deck Principal text = text .. ' \'\'\'DECK PRINCIPAL\'\'\' ' text = text .. ' ' local i = 1 while maindeck.. i ~= nil do local cardname = maindeck.. i text = text .. html.card(cardnamescardname) i = i + 1 end text = text .. ' ' -- Deck Extra text = text .. ' \'\'\'DECK EXTRA\'\'\' ' text = text .. ' ' local i = 1 while extradeck.. i ~= nil do local cardname = extradeck.. i text = text .. html.card(cardnamescardname) i = i + 1 end text = text .. ' ' -- Side Deck text = text .. ' \'\'\'SIDE DECK\'\'\' ' text = text .. ' ' local i = 1 while sidedeck.. i ~= nil do local cardname = sidedeck.. i text = text .. html.cardview(cardnamescardname) i = i + 1 end text = text .. ' \n' -- Tab: 1-15 text = text .. '|-|\n' text = text .. '1-15=\n' text = text .. ' \n' return text end